﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace Faust.Andrew.MTG.Player
{
	/// <summary>
	/// Interaction logic for CounterEditor.xaml
	/// </summary>
	public partial class CounterEditor : Window
	{
        public ObservableCollection<Shared.Counter> Counters;

        public CounterEditor()
        {
            this.InitializeComponent();

            Counters = new ObservableCollection<Shared.Counter>();
            lbCounters.ItemsSource = Counters;
            // Insert code required on object creation below this point.
        }

		private void btnSave_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            DialogResult = true;
            Close();
		}

		private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            DialogResult = false;
            Close();
		}

		private void btnAdd_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            Shared.Counter counter = new Faust.Andrew.MTG.Player.Shared.Counter() 
            { 
                Name = "New Counter", 
                CounterType = Shared.CounterType.Other, 
                Value = 1 
            };

            Counters.Add(counter);
            lbCounters.SelectedItem = counter;
		}

		private void btnDelete_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            Shared.Counter counter = lbCounters.SelectedItem as Shared.Counter;
            if (counter != null)
            {
                Counters.Remove(counter);
            }
		}
	}
}